#include<stdio.h>
#include<assert.h>
#include<stdlib.h>
typedef int StackDateType;
typedef struct Stack
{
	StackDateType* _ps;
	size_t _size;
	size_t _capacity;
}Stack;
void StackInit(Stack* ps)
{
	assert(ps);
	ps->_ps = NULL;
	ps->_size = ps->_capacity = 0;
}
void StackPushBack(Stack* ps, StackDateType val)
{
	assert(ps);
	if (ps->_size == ps->_capacity)
	{
		size_t newcapacity = ps->_capacity == 0 ? 4 : ps->_capacity * 2;
		StackDateType* tmp = (StackDateType*)realloc(ps->_ps, sizeof(StackDateType) * newcapacity);
		if (tmp == NULL)
			exit(1);
		ps->_ps = tmp;
		ps->_capacity = newcapacity;
	}
	ps->_ps[ps->_size] = val;
	ps->_size++;
}
void StackDestory(Stack* ps)
{
	assert(ps);
	free(ps->_ps);
	ps->_capacity = ps->_size = 0;
	ps->_ps = NULL;
	
}
int main1()
{
	Stack s1;
	StackInit(&s1);
	StackPushBack(&s1, 5);
	StackPushBack(&s1, 6);
	StackPushBack(&s1, 5);
	StackPushBack(&s1, 1);
	StackPushBack(&s1, 9);
	StackPushBack(&s1, 6);
	StackDestory(&s1);
	return 0;
}
